package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.DishFlavor;
import com.itheima.reggie.mapper.DishMapper;
import com.itheima.reggie.service.DishFlavorService;
import com.itheima.reggie.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DishServiceImpl extends ServiceImpl<DishMapper, Dish>  implements DishService {
    @Autowired
    private DishFlavorService dishFlavorService;

    @Override
    public void delete(List<Long> ids) {
        for (Long id : ids) {
            this.removeById(id);
            LambdaQueryWrapper<DishFlavor> dfqw = new LambdaQueryWrapper<>();
            dfqw.eq(DishFlavor::getDishId,id);
            dishFlavorService.remove(dfqw);
        }
    }
}
